﻿@using EasyAccess.Authorization
@using EasyAccess.Model.DTOs
@{
    var menus = AuthorizationManager.GetInstance().GetMenu(((FormsIdentity)User.Identity).Ticket.UserData);
    var mainMenus = menus.Where(x => x.Depth == 1 && x.System.Equals("M")).OrderBy(x => x.Depth).ThenBy(x => x.Index);
}
@helper PrintMenu(MenuDto menu, List<MenuDto> menus)
{
    if (string.IsNullOrWhiteSpace(menu.Url))
    {
        var submenus = menus.Where(x => x.Depth.Equals(menu.Depth + 1) && x.ParentId.Equals(menu.Id));
        <div title="@menu.Name">
            @foreach (var submenu in submenus)
            {
                @PrintMenu(submenu, menus);
            }
        </div>
    }
    else
    {
        <a class="nav" href="javascript:;" onclick="global.easyuiHelper.tabs.add('@menu.Name', '@menu.Url', false)">
            @for (int i = 1; i < menu.Depth; i++)
            {
                <text>&nbsp;</text>
            }
            @menu.Name
        </a>
    }
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title</title>
    <link type="text/css" rel="stylesheet" href="~/Scripts/Plugins/EasyUi/themes/icon.css" />
    <link type="text/css" rel="stylesheet" href="~/Scripts/Plugins/EasyUi/themes/metro/easyui.css" />
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/jquery")
    <script type="text/javascript" src="~/Scripts/Plugins/EasyUi/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="~/Scripts/Plugins/EasyUi/locale/easyui-lang-zh_CN.js"></script>
    @Scripts.Render("~/bundles/helper")
    @RenderSection("style", false)
</head>
    <body class="easyui-layout">
        <div data-options="region:'north'" style="height:50px"></div>
        <div data-options="region:'west'" title="菜单" style="width:200px;">
            <div class="easyui-accordion" data-options="fit:true">
                @foreach (var menu in mainMenus)
                {
                    @PrintMenu(menu, menus);
                }
            </div>
        </div>
        <div data-options="region:'center',title:'',iconCls:'icon-ok'">
            <div id="container-tabsTools">
                <a title="关闭全部标签页" href="javascript:easyuiHelper.tabs.closeAll()" class="easyui-linkbutton" data-options="plain:true,iconCls:'icons-tabs_close'"></a>
            </div>
            <div id="container-tabs" class="easyui-tabs" data-options="fit:true,tools:'#container-tabsTools'">
                @RenderBody()
            </div>
        </div>
        <div class="footer" data-options="region:'south'" style="height:50px;">
            <div class="copyright"> © 2013 51b. All rights reserved.</div>
        </div>
        <div style="display: none">
            @RenderSection("hiddenArea", false)
        </div>
        <script src="~/Scripts/require.js" data-main="/Scripts/Global/main"></script>
        @RenderSection("script", required: false)
    </body>
</html>
